#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int search(vector<int>& nums, int target) {
        int left = 0, right = nums.size() - 1;
        while (right >= left)
        {
            int min = left + (right - left) / 2;
            if (nums[min] > target)
            {
                right = min - 1;
            }
            else if (nums[min] < target)
            {
                left = min + 1;
            }
            else
            {
                return min;
            }
        }
        return -1;
    }
};